package com.example.tests;

import org.junit.*;
import com.example.tests.pages.HomePage;
import com.example.tests.pages.LoginPage;
import factories.MyPageFactory;
import static org.junit.Assert.*;

   public class LoginTest extends Browser {

   @Test
   public void testLoginSuccess() throws Exception {
        boolean result = MyPageFactory.getPage(driver, LoginPage.class).login(admin)
            .IsLoginSuccessfull();
        assertTrue(result);
    }

    @Test
    public void testLoginFailed() throws Exception {
        boolean result = MyPageFactory.getPage(driver, LoginPage.class)
            .loginUnsuccesfullAs(admin.getUsername(), "admmm")
            .getLoginErrorText()
            .matches("Incorrect user name or password");
        assertTrue("The password error check failed!", result);
    }
	
    @Test
    public void testLoginErrorClassForUsername() throws Exception {
    boolean result = MyPageFactory.getPage(driver, LoginPage.class).login()
        .isErrorClassAppliedForUsername();
        assertTrue("The updated username field check failed!", result);
    }
	
    @Test
    public void testLoginErrorClassForPassword() throws Exception {
    boolean result = MyPageFactory.getPage(driver, LoginPage.class).login()
        .isErrorClassAppliedForPassword();
        assertTrue("The updated password field check failed!", result);
    }
	
    @Test
    public void testLoginUsernameWarningPresent() throws Exception {
    boolean result = MyPageFactory.getPage(driver, LoginPage.class).login()
        .isUsernameWarningPresent();
        assertTrue("The alert icon appearance test for username field failed!",
            result);
    }
	
    @Test
    public void testLoginPasswordWarningPresent() throws Exception {
        boolean result = MyPageFactory.getPage(driver, LoginPage.class).login()
            .isPasswordWarningPresent();
        assertTrue("The alert icon appearance test for password field failed", 
        result);
    }
}
